<?php
namespace Common\Model;

/**
 * 客栈房间预定信息记录表
 * @modify trainyao 2015-12-31 创建
 * @index roomdetail(roominfo_id)
 */

Class RoomDetailModel extends \Common\Model\BaseModel
{
    protected $trueTableName = 'bk_room_detail';
    
    public function addInfo() {
    }
    
    /**
     * 获取房间预定信息
     * @modify trainyao 2015-12-31 创建
     * @param  mixin   $roomId    房间ID(s)
     * @return array
     */
    public function getInfoByRoom($roomId) {
        $option = array(
            'roominfo_id' => $roomId,
            'isdelete' => NOT_DELETE,
        );

    }

    /**
     * 根据一个或多个房间ID删除上架房间数据
     * @modify trainyao 2016-01-04 创建
     * @param  mixin   $roomId    房间id(s)
     * @return boolean 执行结果
     */
    public function deleteInfoByRoom($roomId) {
        $option = array();

        if(is_array($roomId)) {
            $roomId = implode(',', $roomId);
        }
        if(strpos($roomId, ',') !== false) {
            $option['roominfo_id'] = array('in', $roomId);
        } else {
            $option['roominfo_id'] = $roomId;
        }

        $option['isdelete'] = NOT_DELETE;
        $data = array(
            'isdelete' => IS_DELETE,
        );
        return $this->where($option)->save($data) === false ? false : true;
    }
}
